<form id="form1" method="post">
	<input name="id" id="id" class="mini-hidden" value="0"/>
	<input name="con_agency" id="con_agency" class="mini-hidden" value="0"/>
	<div style="padding-left:11px;padding-bottom:5px;">
		<table style="table-layout:fixed;">
			<tr>
				<td style="width:100px;">员工：</td>
				<td style="width:140px;"><input name="staff_id" id="staff_id" class="mini-buttonedit" required="true" onbuttonclick="onButtonEdit(this,'/common/staff')"/></td>
				<td style="width:100px;">进度：</td>
				<td style="width:140px;"><input name="schedule" id="schedule" vtype="range:0,100" required="true" value="0" class="mini-spinner" style="width:100%;"/></td>
			</tr>
			<tr>
				<td style="width:100px;">备注：</td>
				<td style="width:380px;" colspan="3"><input name="remark" id="remark" class="mini-textarea" style="width:100%;height:80px;" emptyText="请输入描述"/></td>
			</tr>
		</table>
	</div>
	<div style="text-align:center;padding:10px;">   
		<a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>   
		<a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>   
	</div>
</form>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form1");

// 保存数据
function SaveData() {
	form.validate();
	if (form.isValid() == false) return;
	if (mini.get("schedule").getValue()<0 || mini.get("schedule").getValue()>100){
		parent.parent.$.dooDialog.alert("进度输入不正确，请输入0~100直接的值！");
		return false;
	}

	if ($.trim(mini.get("staff_id").getValue()) == $.trim(mini.get("staff_id").getText())){
		parent.parent.$.dooDialog.alert("顾客投诉人不能直接输入，请重新选择！");
		return;
	}
	
	if(mini.get("schedule").getValue() == 100){
		parent.parent.$.dooDialog.confirm("您填写的进度是100%，您确认工单完成了吗？",function(){
			$.ajax({
				type:"POST",
				url:"/business/businessScheduleEdit",
				data:{data:form.getData()},
				cache: false,
				success: function (text) {
					CloseWindow("save");
				},
				error: function (jqXHR, textStatus, errorThrown) {
					CloseWindow();
				}
			});
		});
	}else{
		$.ajax({
			type:"POST",
			url:"/business/businessScheduleEdit",
			data:{data:form.getData()},
			cache: false,
			success: function (text) {
				CloseWindow("save");
			},
			error: function (jqXHR, textStatus, errorThrown) {
				CloseWindow();
			}
		});
	}
}

// 设置数据
function SetData(data) {
	if (data.action == "edit") {
		data = mini.clone(data);
		mini.get("id").setValue(data.id);
		mini.get("schedule").setValue(data.schedule);
		mini.get("con_agency").setValue(data.con_agency);
	}
}

// 关闭窗口
function CloseWindow(action) {
	if (action == "close" && form.isChanged()) {
		if (confirm("数据被修改了，是否先保存？")) {
			return false;
		}
	}
	if (window.CloseOwnerWindow){
		return window.CloseOwnerWindow(action);
	}else{
		window.close();
	}
}

// 保存数据
function onOk(e) {
	SaveData();
}

// 取消数据
function onCancel(e) {
	CloseWindow("cancel");
}
</script>
